package com.pounds.control;

import com.pounds.pojo.User;
import com.pounds.pojo.UserInfo;
import com.pounds.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@CrossOrigin
@RestController
@RequestMapping("harryserver/user")
public class UserControl {

    @Autowired
    private UserService userService;

    @GetMapping("test")
    public List<User> loopAllUser(){
        return userService.loopAllUser();
    }

    @GetMapping("register")
    public String register(String username,String account,String password){
        return userService.register(username,account,password);
    }

    @GetMapping("login")
    public String login(String account,String password){
        return userService.login(account,password);
    }

    @GetMapping("get_info")
    public List<UserInfo> GetUserInfo(String account){
        return userService.GetUserInfo(account);
    }

    @GetMapping("set_info")
    public String SetUserInfo(String username,String account,String sex,int age,String introduce){
        return userService.SetUserInfo(username,account,sex,age,introduce);
    }

    @GetMapping("change_password")
    public String ChangePassword(String account,String old_password,String new_password){
        return userService.ChangePassword(account,old_password,new_password);
    }
}
